home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / python-support / gnome-orca / orca / keynames.py < prev    next >
Encoding:
Python Source  |  2009-04-13  |  7.7 KB  |  264 lines

  1. # Orca
  2. #
  3. # Copyright 2006-2008 Sun Microsystems Inc.
  4. #
  5. # This library is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Library General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 2 of the License, or (at your option) any later version.
  9. #
  10. # This library is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. # Library General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Library General Public
  16. # License along with this library; if not, write to the
  17. # Free Software Foundation, Inc., Franklin Street, Fifth Floor,
  18. # Boston MA  02110-1301 USA.
  19.  
  20. """Exposes a dictionary, keynames, that maps key events
  21. into localized words."""
  22.  
  23. __id__        = "$Id: keynames.py 4045 2008-07-18 13:20:37Z wwalker $"
  24. __version__   = "$Revision: 4045 $"
  25. __date__      = "$Date: 2008-07-18 09:20:37 -0400 (Fri, 18 Jul 2008) $"
  26. __copyright__ = "Copyright (c) 2006-2008 Sun Microsystems Inc."
  27. __license__   = "LGPL"
  28.  
  29. import chnames
  30.  
  31. from orca_i18n import _ # for gettext support
  32.  
  33. # __keynames is a dictionary where the keys represent a UTF-8
  34. # string for a keyboard key and the values represent the common
  35. # phrase used to describe the key.
  36. #
  37. __keynames = {}
  38.  
  39. # Translators: this is how someone would speak the name of the left shift key
  40. #
  41. __keynames["Shift_L"]      = _("left shift")
  42.  
  43. # Translators: this is how someone would speak the name of the left alt key
  44. #
  45. __keynames["Alt_L"]        = _("left alt")
  46.  
  47. # Translators: this is how someone would speak the name of the left ctrl key
  48. #
  49. __keynames["Control_L"]    = _("left control")
  50.  
  51. # Translators: this is how someone would speak the name of the right shift key
  52. #
  53. __keynames["Shift_R"]      = _("right shift")
  54.  
  55. # Translators: this is how someone would speak the name of the right alt key
  56. #
  57. __keynames["Alt_R"]        = _("right alt")
  58.  
  59. # Translators: this is how someone would speak the name of the right ctrl key
  60. #
  61. __keynames["Control_R"]    = _("right control")
  62.  
  63. # Translators: this is how someone would speak the name of the left meta key
  64. #
  65. __keynames["Meta_L"]       = _("left meta")
  66.  
  67. # Translators: this is how someone would speak the name of the right meta key
  68. #
  69. __keynames["Meta_R"]       = _("right meta")
  70.  
  71. # Translators: this is how someone would speak the name of the num lock key
  72. #
  73. __keynames["Num_Lock"]     = _("num lock")
  74.  
  75. # Translators: this is how someone would speak the name of the caps lock key
  76. #
  77. __keynames["Caps_Lock"]    = _("caps lock")
  78.  
  79. # Translators: this is how someone would speak the name of the scroll lock key
  80. #
  81. __keynames["Scroll_Lock"]  = _("scroll lock")
  82.  
  83. # Translators: this is how someone would speak the name of the page up key
  84. #
  85. __keynames["Page_Up"]      = _("page up")
  86.  
  87. # Translators: this is how someone would speak the name of the page up key
  88. #
  89. __keynames["KP_Page_Up"]      = _("page up")
  90.  
  91. # Translators: this is how someone would speak the name of the page up key
  92. #
  93. __keynames["Prior"]      = _("page up")
  94.  
  95. # Translators: this is how someone would speak the name of the page up key
  96. #
  97. __keynames["KP_Prior"]      = _("page up")
  98.  
  99. # Translators: this is how someone would speak the name of the page down key
  100. #
  101. __keynames["Page_Down"]    = _("page down")
  102.  
  103. # Translators: this is how someone would speak the name of the page down key
  104. #
  105. __keynames["KP_Page_Down"]    = _("page down")
  106.  
  107. # Translators: this is how someone would speak the name of the page down key
  108. #
  109. __keynames["Next"]    = _("page down")
  110.  
  111. # Translators: this is how someone would speak the name of the page down key
  112. #
  113. __keynames["KP_Next"]    = _("page down")
  114.  
  115. # Translators: this is how someone would speak the name of the tab key
  116. #
  117. __keynames["Tab"] = _("tab")
  118.  
  119. # Translators: this is how someone would speak the name of the left tab key
  120. #
  121. __keynames["ISO_Left_Tab"] = _("left tab")
  122.  
  123. # Translators: this is how someone would speak the name of the F11 key
  124. #
  125. __keynames["SunF36"]       = _("F 11")
  126.  
  127. # Translators: this is how someone would speak the name of the F12 key
  128. #
  129. __keynames["SunF37"]       = _("F 12")
  130.  
  131. # Translators: this is the spoken word for the space character
  132. #
  133. __keynames["space"] = _("space")
  134.  
  135. # Translators: this is how someone would speak the name of the backspace key
  136. #
  137. __keynames["BackSpace"] = _("backspace")
  138.  
  139. # Translators: this is how someone would speak the name of the return key
  140. #
  141. __keynames["Return"] = _("return")
  142.  
  143. # Translators: this is how someone would speak the name of the enter key
  144. #
  145. __keynames["KP_Enter"] = _("enter")
  146.  
  147. # Translators: this is how someone would speak the name of the up arrow key 
  148. #
  149. __keynames["Up"] = _("up")
  150.  
  151. # Translators: this is how someone would speak the name of the up arrow key 
  152. #
  153. __keynames["KP_Up"] = _("up")
  154.  
  155. # Translators: this is how someone would speak the name of the down arrow key 
  156. #
  157. __keynames["Down"] = _("down")
  158.  
  159. # Translators: this is how someone would speak the name of the down arrow key 
  160. #
  161. __keynames["KP_Down"] = _("down")
  162.  
  163. # Translators: this is how someone would speak the name of the left arrow key 
  164. #
  165. __keynames["Left"] = _("left")
  166.  
  167. # Translators: this is how someone would speak the name of the left arrow key 
  168. #
  169. __keynames["KP_Left"] = _("left")
  170.  
  171. # Translators: this is how someone would speak the name of the right arrow key 
  172. #
  173. __keynames["Right"] = _("right")
  174.  
  175. # Translators: this is how someone would speak the name of the right arrow key 
  176. #
  177. __keynames["KP_Right"] = _("right")
  178.  
  179. # Translators: this is how someone would speak the name of the left super key 
  180. #
  181. __keynames["Super_L"] = _("left super")
  182.  
  183. # Translators: this is how someone would speak the name of the right super key 
  184. #
  185. __keynames["Super_R"] = _("right super")
  186.  
  187. # Translators: this is how someone would speak the name of the menu key 
  188. #
  189. __keynames["Menu"] = _("menu")
  190.  
  191. # Translators: this is how someone would speak the name of the ISO shift key 
  192. #
  193. __keynames["ISO_Level3_Shift"] = _("ISO level 3 shift")
  194.  
  195. # Translators: this is how someone would speak the name of the help key 
  196. #
  197. __keynames["Help"] = _("help")
  198.  
  199. # Translators: this is how someone would speak the name of the multi key 
  200. #
  201. __keynames["Multi_key"] = _("multi")
  202.  
  203. # Translators: this is how someone would speak the name of the mode switch key 
  204. #
  205. __keynames["Mode_switch"] = _("mode switch")
  206.  
  207. # Translators: this is how someone would speak the name of the escape key 
  208. #
  209. __keynames["Escape"] = _("escape")
  210.  
  211. # Translators: this is how someone would speak the name of the insert key
  212. #
  213. __keynames["Insert"] = _("insert")
  214.  
  215. # Translators: this is how someone would speak the name of the insert key
  216. #
  217. __keynames["KP_Insert"] = _("insert")
  218.  
  219. # Translators: this is how someone would speak the name of the delete key
  220. #
  221. __keynames["Delete"] = _("delete")
  222.  
  223. # Translators: this is how someone would speak the name of the delete key
  224. #
  225. __keynames["KP_Delete"] = _("delete")
  226.  
  227. # Translators: this is how someone would speak the name of the home key
  228. #
  229. __keynames["Home"] = _("home")
  230.  
  231. # Translators: this is how someone would speak the name of the home key
  232. #
  233. __keynames["KP_Home"] = _("home")
  234.  
  235. # Translators: this is how someone would speak the name of the end key
  236. #
  237. __keynames["End"] = _("end")
  238.  
  239. # Translators: this is how someone would speak the name of the end key
  240. #
  241. __keynames["KP_End"] = _("end")
  242.  
  243. # Translators: this is how someone would speak the name of the begin key
  244. #
  245. __keynames["KP_Begin"] = _("begin")
  246.  
  247. def getKeyName(key):
  248.     """Given a keyboard key, return its name as people might refer to it
  249.     in ordinary conversation.
  250.  
  251.     Arguments:
  252.     - key: the key to get the name for
  253.  
  254.     Returns a string representing the name for the key
  255.     """
  256.  
  257.     if isinstance(key, unicode):
  258.         key = key.encode("UTF-8")
  259.  
  260.     try:
  261.         return __keynames[key]
  262.     except:
  263.         return chnames.getCharacterName(key)
  264.